# -*- coding: utf-8 -*-
"""
Created on Thu Sep 19 17:20:20 2024

@author: Administrator
"""
from tkinter import *
import time 

def ballMove(event,canvas,objId):
    
    if(event.keysym == "Left"):
        canvas.move(objId,-5,0)
        
    if event.keysym == "Right":
       canvas.move(objId,5,0)
       
    if(event.keysym == "Up"):
       canvas.move(objId,0,-5)
       
    if(event.keysym == "Down"):
        canvas.move(objId,0,5)
        
tk = Tk()

canvas = Canvas(tk,width=800,height=600)

canvas.pack()
objId=canvas.create_oval(400,300,420,320,fill="green")

canvas.bind_all('<KeyPress>', lambda event: ballMove(event, canvas, objId))



tk.mainloop()